package com.kfm.am;

public class BankAccount {

    private String accountNumber;
    private String accountHolder;
    private double balance;

    public BankAccount() {
    }

    public BankAccount(String accountNumber, String accountHolder) {
        this.accountNumber = accountNumber;
        this.accountHolder = accountHolder;
    }

    public String getAccountNumber() {
        return this.accountNumber;
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    public String getAccountHolder() {
        return this.accountHolder;
    }

    public void setAccountHolder(String accountHolder) {
        this.accountHolder = accountHolder;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public String info() {
        return "账户名称：" + this.accountHolder + ", 账户编号：" + this.accountNumber + "，账户余额：" + this.balance;
    }

    public boolean saveMoney(double money) {
        if (money > 0) {
            this.balance += money;
            return true;
        } else {
            System.out.println("你输入的钱不对！");
            return false;
        }
    }

    public boolean drawMoney(double money) {
        if (money < 0) {
            System.out.println("你输入的钱不对！");
            return false;
        } else {
            if (balance < money) {
                System.out.println("余额不足，你心里没数嘛");
                return false;
            }
            balance -= money;
            return true;
        }
    }
}
